From: Ian Campbell Date: Wed, 3 Jan 2007 13:55:53 +0000 (+0000) Subject: [IOEMU] Process reset requests before returning control to the guest. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15422^2~99 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=49f1cd42a181a4123c28e8262bc3c219e2dc74d4;p=xen.git [IOEMU] Process reset requests before returning control to the guest. Since 12899:4ae4bdee00e Xen only pays attention the first shutdown or reboot request for a domain. When a reset if requested we need to make the SCHEDOP_remote_shutdown hypercall before we return control to the guest so that it wins the "race" with the heuristic in xen/arch/x86/hvm/hvm.c:hvm_vcpu_down() which causes a powerdown. Signed-off-by: Ian Campbell --- diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c index aa7b042561..ae84b9ed23 100644 --- a/tools/ioemu/target-i386-dm/helper2.c +++ b/tools/ioemu/target-i386-dm/helper2.c @@ -498,6 +498,8 @@ void handle_buffered_io(void *opaque) void cpu_handle_ioreq(void *opaque) { + extern int vm_running; + extern int shutdown_requested; CPUState *env = opaque; ioreq_t *req = cpu_get_ioreq(); @@ -516,6 +518,25 @@ void cpu_handle_ioreq(void *opaque) } wmb(); /* Update ioreq contents /then/ update state. */ + + /* + * We do this before we send the response so that the tools + * have the opportunity to pick up on the reset before the + * guest resumes and does a hlt with interrupts disabled which + * causes Xen to powerdown the domain. + */ + if (vm_running) { + if (shutdown_requested) { + fprintf(logfile, "shutdown requested in cpu_handle_ioreq\n"); + destroy_hvm_domain(); + } + if (reset_requested) { + fprintf(logfile, "reset requested in cpu_handle_ioreq.\n"); + qemu_system_reset(); + reset_requested = 0; + } + } + req->state = STATE_IORESP_READY; xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]); }